#ifndef SQL_H
#define SQL_H

#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QDebug>
#include <QFile>

class SqlHelper
{
public:
    static SqlHelper& getInstance();

    SqlHelper();
    ~SqlHelper();

    SqlHelper(const SqlHelper&) = delete;
    SqlHelper& operator=(const SqlHelper&) = delete;


    QSqlDatabase db;

    void createConnection();
    void createTables();
    void deleteDataBase();

public:
    bool insertTeacher(const QString &name, const QString &college, const QString &department, const QString &title);
    QList<QVariantList> queryTeachers();
    QVariantList queryTeacherByName(const QString &name);
    bool insertCourse(const QString &code, const QString &name, const QString &type, const QString &semester, int credits, int studentCount, const QString &teacher_name);
    QList<QVariantList> queryCourses();
    QList<QPair<QString, QString>> queryCoursesForUser(const QString& username);
    QVariantList queryCourseByCourseCode(const QString &courseCode);
    bool insertEvaluation(const QString &courseCode, int selfEvaluation, int studentEvaluation, int supervisorEvaluation, int peerEvaluation);
    QList<QVariantList> queryEvaluations();
    QList<QVariantList> queryEvaluationsForTeacher(const QString &teacherName);
    bool insertStudent(const QString &name, const QString &enrolledCourses);
    QList<QVariantList> queryStudents();
    bool insertUser(const QString &username, const QString &password, const QString &userType);
    QList<QVariantList> queryUsers();
    bool insertEvaluationWeight(const QString& evaluationType, double weight);
    QMap<QString, double> queryEvaluationWeights() const;
    bool updateEvaluation(const QString &courseCode, const QString &evaluationType, double evaluationValue);


};

#endif // SQL_H
